Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-koa): Ensure unhandled Koa errors are logged out #614

Merged
merged 2 commits into from
Aug 16, 2019

Conversation

bengourley
Copy link
Contributor

Our plugin adds an "onerror" handler to the Koa app, which stops the default from being called.

The default error handler which prints the error is available at ctx.app.onerror so by calling through to that after notifying, it exhibits the default behaviour.

Tested manually with notifyReleaseStages both allowing and preventing delivery and added a unit test to ensure the original handler is called.

Output before:

[bugsnag] Report not sent due to releaseStage/notifyReleaseStages configuration

Output after:

[bugsnag] Report not sent due to releaseStage/notifyReleaseStages configuration

  Error: Invalid DSL syntax
      at /Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/app.js:29:29
      at dispatch (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
      at next (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
      at /Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/lib/router.js:346:16
      at dispatch (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
      at /Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/node_modules/koa-compose/index.js:36:12
      at dispatch (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-router/lib/router.js:351:31)
      at dispatch (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-compose/index.js:42:32)
      at requestHandler (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/dist/bugsnag-koa.js:778:15)
      at dispatch (/Users/bengourley/Development/bugsnag-js/packages/plugin-koa/scratch/node_modules/koa-compose/index.js:42:32)

Fixes #602

@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Aug 16, 2019

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.89 kB 12.24 kB
After 40.89 kB 12.24 kB
± No change No change

Generated by 🚫 dangerJS against 41120d3

// this function will throw if you give it a non-error, but we still want
// to output that, so if it throws, pass it back what it threw (a TypeError)
ctx.app.onerror(err)
} catch (e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bugsnag swallows error logging in node/koa
3 participants